package homework.work9;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 浏览器发送过来的请求内容每个字符单独读取出来并输出到控制台
 * @author Xiloer
 *
 */
public class Test02 {
    private ServerSocket serverSocket;
    public Test02() {
        try {
            serverSocket = new ServerSocket(8088);
            System.out.println("服务器启动成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start() {
        try {
            System.out.println("服务器等待连接...");
            Socket socket = serverSocket.accept();
            System.out.println("一个客户端连接成功");
            ClientHandler clientHandler = new ClientHandler(socket);
            Thread t = new Thread(clientHandler);
            t.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Test02 tt = new Test02();
        tt.start();
    }
}
